package movee.kafka.consumer.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.listener.AcknowledgingMessageListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/**
 *
 *
 * @author movee
 */
@Component
@Slf4j
public class TopoMessageListener implements AcknowledgingMessageListener<String, byte[]> {

    @Override
    public void onMessage(final ConsumerRecord<String, byte[]> data, Acknowledgment acknowledgment) {

        try {
            // 业务处理逻辑

            acknowledgment.acknowledge();
        } catch (Exception e) {
            log.error(ExceptionUtils.getStackTrace(e));
        }
    }
}
